
package example.runner2;

import service.network.NetworkManageService;
import materials.network.AbstractNetworkCreation;
import materials.network.NetworkCreation;
import materials.network.NetworkInterface;
import materials.network.NeuronalNetwork;
import materials.neurons.Neurons;

/**
 * Nur zum Netze erstellen gedacht.
 * 
 * @author Ramox
 * 
 */
public class RunnerNetz extends AbstractNetworkCreation {

	public RunnerNetz() {
		createNet();
	}

	/**
	 * erstellt ein neues zufälliges Netz
	 * 
	 * die Neuronen sind so eingeteilt: 25-25-8 mit sigmoid funktionen
	 * 
	 * @return neues Netz
	 */
	private void createNet() {
		NetworkInterface n = new NeuronalNetwork();

		NetworkManageService nms = new NetworkManageService(n);

		nms.raiseLayer();
		nms.raiseLayer();
		 nms.raiseLayer();

		for (int i = 1; i < 26; i++) {
			nms.addNeuronToNetwork(1, "a" + i, Neurons.Linear);
		}

		for (int i = 26; i < 51; i++) {
			nms.addNeuronToNetwork(2, "a" + i, Neurons.Sigmoid);
		}

		for (int i = 51; i < 59; i++) {
			nms.addNeuronToNetwork(3, "a" + i, Neurons.Sigmoid);
		}

		for (int i = 1; i < 26; i++) {
			for (int j = 26; j < 51; j++) {
				nms.connectTwoNeurons(1, "a"+i, "a"+j);
				nms.setWeightOfTwoNeurons(1, "a" + i, "a" + j,
						Math.random() - 0.5);
			}
		}

		for (int i = 26; i < 51; i++) {
			for (int j = 51; j < 59; j++) {
				nms.connectTwoNeurons(2, "a"+i, "a"+j);
				nms.setWeightOfTwoNeurons(2, "a" + i, "a" + j,
						Math.random() - 0.5);
			}
		}

		addNet(n);
	}
}
